package com.loser.module.user.service.impl;

import com.loser.module.room.entity.Room;
import com.loser.module.room.service.RoomService;
import com.loser.module.user.entity.User;
import com.loser.module.user.service.UserService;
import io.github.loserya.config.MogoConfiguration;
import io.github.loserya.core.entity.Page;
import io.github.loserya.core.sdk.impl.MogoServiceImpl;
import io.github.loserya.core.sdk.mapper.BaseMapper;
import io.github.loserya.core.wrapper.LambdaQueryWrapper;
import io.github.loserya.module.datasource.MongoDs;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;

import java.util.Collection;
import java.util.List;

/**
 * 测试数据 实现类
 *
 * @author loser
 * @date 2023-02-05  13:58
 */
@Service
//@Transactional
public class UserServiceImpl extends MogoServiceImpl<String, User> implements UserService {

    public UserServiceImpl() {
        System.out.println(1111);
    }

    @Override
    public MogoConfiguration getConfiguration() {
        return super.getConfiguration();
    }

    @Override
    public BaseMapper<String, User> getMapper() {
        return super.getMapper();
    }

    @Override
    public MongoTemplate getTemplate() {
        return super.getTemplate();
    }

    @Override
    public User getOne(LambdaQueryWrapper<User> queryWrapper) {
        return super.getOne(queryWrapper);
    }

    @Override
    public boolean save(User entity) {
        return super.save(entity);
    }

    @Override
    @MongoDs("slave_1")
    public boolean saveBatch(Collection<User> entityList) {
        return super.saveBatch(entityList);
    }

    @Override
    public boolean removeById(String id) {
        return super.removeById(id);
    }

    @Override
    public boolean remove(LambdaQueryWrapper<User> queryWrapper) {
        return super.remove(queryWrapper);
    }

    @Override
    public boolean updateById(User entity) {
        return super.updateById(entity);
    }

    @Override
    public boolean update(User entity, LambdaQueryWrapper<User> queryWrapper) {
        return super.update(entity, queryWrapper);
    }

    @Override
    public Collection<User> listByIds(Collection<String> idList) {
        return super.listByIds(idList);
    }

    @Override
    public long count(LambdaQueryWrapper<User> queryWrapper) {
        return super.count(queryWrapper);
    }

    @Override
    public List<User> list(LambdaQueryWrapper<User> queryWrapper) {
        return super.list(queryWrapper);
    }

    @Override
    public Page<User> page(LambdaQueryWrapper<User> queryWrapper, int pageNo, int pageSize) {
        return super.page(queryWrapper, pageNo, pageSize);
    }

    @Override
    public boolean exist(LambdaQueryWrapper<User> queryWrapper) {
        return super.exist(queryWrapper);
    }


    @Override
    @MongoDs("master")
    public User getById(String id) {
        return super.getById(id);
    }


    @Override
//    @MongoDs("slave_1")
    public List<User> listByDs1() {
        return super.list();
    }

    @Override
//    @MongoDs("slave_2")
    public List<User> listByDs2() {
        return super.list();
    }

    @Autowired
    private RoomService roomService;

    @Override
    @MongoDs("slave_1")
    public List<User> listByDs3() {
        List<Room> rooms = roomService.listByDs1();
        return super.list();
    }

    @Override
//    @IgnoreLogic
    public List<User> listIgnore1() {
        return super.list();
    }

    @Override
    public List<User> listIgnore2() {
        List<Room> rooms = roomService.listByDs1();
        return super.list();
    }


}
